﻿using System.Text;

namespace ActiveSupport.Conversions
{
    public static class ArrayConversionExtensions
    {

        /// <summary>
        /// Will take in a string array and return a delimited string
        /// This will NOT put spaces between the values.
        /// Semple output
        /// a,b,c,d
        /// </summary>
        /// <param name="value"></param>
        /// <param name="delimitor"></param>
        /// <returns></returns>
        public static string ToDelimitedString( this string[] value, string delimitor )
        {
            StringBuilder builder = new StringBuilder();

            for ( int i = 0; i <= value.Length - 1; i++ )
            {
                builder.Append( value[ i ] );

                if ( i < value.Length - 1 )
                {
                    builder.Append( delimitor );
                }
            }
            
            return builder.ToString();
        }

    }
}
